<? $page_title='年度采购汇总' ?>
<?include "FASHION/page_header.phtml"?>
<div id="printArea">
<table class="ptop" border="0" cellpadding="4" cellspacing="0" width="100%">
         <thead>
            <tr class="nobg">
                <th><h2><?$print_com_name?></h2></th>
            </tr>
            <tr class="nobg">
                <th><h1><?$page_title?></h1></th>
            </tr>
        </thead>        
    </table>
<table border=0 class="list dept" width="100%">
    <caption>按部门</caption> 
	<tr class="nobg">
		<th>月份</th>
	<{foreach item=month from=$months}>
		<th><{$month}>月</th>
	<{/foreach}>
		<th>累计</th>
		<th>平均</th>
	</tr>
<{foreach item=dept key=dept_id from=$data.dept}>
	<tr class="_data">
		<td><{$dept.name}></td>
	<{foreach item=month from=$months}>
		<td class="fnum"><{$dept.month[$month]}></td>
	<{/foreach}>
		<td class="fnum"><{$dept.total}></td>
		<td class="fnum"><{if count($dept.month) }><{= $dept.total/count($dept.month) }><{/if}></td>
	</tr>
<{/foreach}>
	<tr class="tail">
		<td>合计</td>
		<?= str_repeat('<td></td>', 13) ?>
		<td>/</td>
	</tr>
</table>

<table border="0" class="list supplier">
    <caption>按供应商</caption>
	<tr class="nobg">
		<th>月份</th>
	<{foreach item=month from=$months}>
		<th><{$month}>月</th>
	<{/foreach}>
		<th>累计</th>
		<th>平均</th>
	</tr>
<{if $suppliers}><{foreach item=supplier from=$suppliers}>
<{if $data.supplier[$supplier.id].total > 0}>
	<tr class="_data">
		<td><{$supplier.name}></td>
	<{foreach item=month from=$months}>
		<td class="fnum"><{$data.supplier[$supplier.id].month[$month]}></td>
	<{/foreach}>
		<td class="fnum"><{$data.supplier[$supplier.id].total }></td>
		<td class="fnum"><{if count($data.supplier[$supplier.id].month) }>
			<{= $data.supplier[$supplier.id]['total'] / count($data.supplier[$supplier.id].month) }>
			<{/if}></td>
	</tr>
<{/if}>
<{/foreach}><{/if}>
	<tr class="tail">
		<td>合计</td>
		<?= str_repeat('<td></td>', 13) ?>
		<td>/</td>
	</tr>
</table>

<table border="0" class="list type">
    <caption>按类型</caption>
	<tr class="nobg">
		<th>月份</th>
	<{foreach item=month from=$months}>
		<th><{$month}>月</th>
	<{/foreach}>
		<th>累计</th>
		<th>平均</th>
	</tr>
<{foreach item=type key=typeid from=array('补库采购','专项采购','紧急采购')}>
	<tr class="_data">
		<td><{$type}></td>
	<{foreach item=month from=$months}>
		<td class="fnum"><{$data.type[$typeid].month[$month]}></td>
	<{/foreach}>
		<td class="fnum"><{ $data.type[$typeid].total }></td>
		<td class="fnum"><{if count($data.type[$typeid].month) }>
			<{= $data.type[$typeid]['total'] / count($data.type[$typeid].month) }>
			<{/if}></td>
	</tr>
<{/foreach}>
	<tr class="tail">
		<td>合计</td>
		<?= str_repeat('<td></td>', 13) ?>
		<td>/</td>
	</tr>
</table>
</div>
<script>
(function(){
	function sum(type){
		$('.list.'+type+' tr.tail td').each(function(id, obj){
			if(id>0 && id<14){
				var total = 0.0;
				$('.list.'+type+' tr._data').each(function(){
					_val = parseFloat( $(this).children('td').eq(id).html() );
					if(_val){ total += _val; }
				});
				$(obj).html(round(total=='0'?'':total));
			}
		});
	}
	sum('dept');
	sum('supplier');
	sum('type');
})();
</script>

<?include "FASHION/page_footer.phtml"?>
